package com.manage.server.config;

import com.manage.server.interceptor.JwtUserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private JwtUserInterceptor jwtUserInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtUserInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/login",
                        "/com/manage/static/avatars/**"  // 精确匹配访问路径
                );
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/com/manage/static/avatars/**")
                .addResourceLocations("file:D:/study/code/idea/ideaProject/SysManage/server/src/main/resources/com/manage/static/avatars/");
    }
}